package ch7;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

//JSTL测试
@WebServlet(name = "CompanyServlet",value = "/jstl")
public class CompanyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request,
                          HttpServletResponse response)
            throws ServletException, IOException {
doGet(request, response);
    }

    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response)
            throws ServletException, IOException {
//        List<Company> companyList = new ArrayList<>();
//        companyList.add(new Company("百度","www.baidu.com"));
        List<Company> companyList = new ArrayList<>();
        Company company1 = new Company();
        company1.setCname("华为");
        company1.setUrl("www.huawei.com");
        Company company2 = new Company();
        company2.setCname("百度");
        company2.setUrl("www.baidu.com");
        Company company3 = new Company();
        company3.setCname("腾讯");
        company3.setUrl("www.qq.com");
        Company company4 = new Company();
        company4.setCname("小凯视频平台");
        company4.setUrl("https://ma-zaiwei.gitee.io/shopping-project/#/find/sort");
        companyList.add(company1);
        companyList.add(company2);
        companyList.add(company3);
        companyList.add(company4);
        request.setAttribute("company",companyList);
        request.getRequestDispatcher("/Company.jsp").forward(request,response);
    }
}
